<include file="Public:header" />
    <div class="container">

      <div class="blog-header">
        <h1 class="blog-title">发布宝贝</h1>
        <p class="lead blog-description">小市场，大甩卖，让闲置物跳回家。</p>
      </div>

      <div class="row">

        <div class="col-sm-8 blog-main">
            <form class="form-horizontal" action="/User/addbaby_do" method="POST" enctype="multipart/form-data">
            <fieldset>
            <div class="form-group">

                  <!-- Text input-->
                  <label class="control-label col-sm-2" for="input01">宝贝名称</label>
                  <div class="col-sm-4">
                    <input type="text" placeholder="宝贝名称" name="babyname" class="form-control">
                    <p class="help-block"></p>
                  </div>
                </div>

            <div class="form-group">
                  <!-- Select Basic -->
                  <label class="control-label col-sm-2">类目</label>
                  <div class="col-sm-4">
                    <select name="category" class="form-control">
                      <foreach name="catelist" item="vo">
                    <option value="{$vo.cateid}">{$vo.catename}</option>
                      </foreach>
              </select>
                  </div>
            </div>

            <div class="form-group">

                  <!-- Text input-->
                  <label class="control-label col-sm-2" for="input01">价格</label>
                  <div class="col-sm-4">
                    <input type="text" name="babymoney" placeholder="价格" class="form-control">
                    <p class="help-block"></p>
                  </div>
                </div>
            <foreach name="userinfo" item="vo">
            <div class="form-group">
                  <input type="hidden" value="{$vo.username}" name="stunum">
                  <!-- Text input-->
                  <label class="control-label col-sm-2" for="input01">联系方式</label>
                  <div class="col-sm-4">
                    <input type="text" name="phone" placeholder="" value="{$vo.phone}" ="" class="form-control">
                    <p class="help-block">*联系方式不会对外公布，可放心填写</p>
                  </div>
            </div>

            <div class="form-group">

                  <!-- Text input-->
                  <label class="control-label col-sm-2" for="input01">QQ号</label>
                  <div class="col-sm-4">
                    <input type="text" name="qq" placeholder="" value="{$vo.qq}" class="form-control">
                    <p class="help-block">*QQ号不会对外公布，可放心填写</p>
                  </div>
            </div>
            
            <div class="form-group">
                  <!-- Text input-->
                  <label class="control-label col-sm-2" for="input01">姓名</label>
                  <div class="col-sm-4">
                    <input type="text" name="clientname" value="{$vo.turename}" class="form-control">
                    <p class="help-block"></p>
                  </div>
                </div>
            </foreach>
            <div class="form-group">
                  <!-- Text input-->
                  <label class="control-label col-sm-2" for="input01">交易地点</label>
                  <div class="col-sm-4">
                    <input type="text" name="address" placeholder="交易地点" class="form-control">
                    <p class="help-block">*校园内交易</p>
                  </div>
            </div>

            <div class="form-group">
                  <!-- Textarea -->
                  <label class="control-label col-sm-2">宝贝描述</label>
                  <div class="col-sm-4">
                    <div class="textarea">
                          <textarea type="" name="babycont" class="" style="margin: 0px; width: 264px; height: 78px;"> </textarea>
                    </div>
                  </div>
            </div>
            <div class="uploadimg">
              <div class="form-group imgfloat">
            <label class="control-label">上传宝贝图片：</label>
                <div class="controls">
                  <div type="button" class="btn btn-primary up-file-bt">选择图片<input class="up-file-hiden" type="file" multiple="multiple" id="picfile" /></div>
                  <span class="btn btn-primary picup" mtype="pic">上传</span>
                  <input type="hidden" name="picurl" value="">
                  <span class="help-inline"></span>
                  <br />
                  <img src="/Public/Matrix/images/nophoto.jpg" style="margin-top:10px;" id="readimg" class="img-circle" width="150px" height="150px" />
                </div>
            </div>

            <div class="form-group imgfloat">
            <label class="control-label">上传宝贝图片：</label>
                <div class="controls">
                  <div type="button" class="btn btn-primary up-file-bt">选择图片<input class="up-file-hiden" type="file" multiple="multiple" id="picfile1" /></div>
                  <span class="btn btn-primary picup1" mtype="pic">上传</span>
                  <input type="hidden" name="picurl1" value="">
                  <span class="help-inline"></span>
                  <br />
                  <img src="/Public/Matrix/images/nophoto.jpg" style="margin-top:10px;" id="readimg1" class="img-circle" width="150px" height="150px" />
                </div>
            </div>

            <div class="form-group imgfloat">
            <label class="control-label">上传宝贝图片：</label>
                <div class="controls">
                  <div type="button" class="btn btn-primary up-file-bt">选择图片<input class="up-file-hiden" type="file" multiple="multiple" id="picfile2" /></div>
                  <span class="btn btn-primary picup2" mtype="pic">上传</span>
                  <input type="hidden" name="picurl2" value="">
                  <span class="help-inline"></span>
                  <br />
                  <img src="/Public/Matrix/images/nophoto.jpg" style="margin-top:10px;" id="readimg2" class="img-circle" width="150px" height="150px" />
                </div>
            </div>
            </div>
                <div class="control-group">
                  <label class="control-label"></label>
                  <!-- Button -->
                  <div class="col-sm-4">
                    <button class="btn btn-success">发布宝贝</button>
                  </div>
                </div>

            </fieldset>
          </form>
        </div><!-- /.blog-main -->

        <div class="col-sm-3 col-sm-offset-1 blog-sidebar">
          <div class="sidebar-module sidebar-module-inset">
            <h4>About</h4>
            <p>Etiam porta <em>sem malesuada magna</em> mollis euismod. Cras mattis consectetur purus sit amet fermentum. Aenean lacinia bibendum nulla sed consectetur.</p>
          </div>
          <div class="sidebar-module">
            <h4>Archives</h4>
            <ol class="list-unstyled">
              <li>挥泪卖学长</li>
              <li>满50送性感学姐</li>
              <li>白天可以么么哒</li>
              <li>晚上可以啪啪啪</li>
              <li>口加手，齐建跳蚤市场，齐创旧货价值</li>
            </ol>
          </div>
          <div class="sidebar-module">
            <h4><b>学长的店</b></h4>
            <ol class="list-unstyled">
              <li><a href="#">GitHub</a></li>
              <li><a href="#">Twitter</a></li>
              <li><a href="#">Facebook</a></li>
            </ol>
          </div>
        </div><!-- /.blog-sidebar -->

      </div><!-- /.row -->

    </div><!-- /.container -->
<script type="text/javascript">
  $('.picup').click(function() {
    var modeltype = $(this).attr('mtype')
    var data = new FormData()
    for(var key in document.getElementById(modeltype+'file').files) {
        data.append(modeltype+'[]', document.getElementById(modeltype+'file').files[key]);
      }
    if(document.getElementById(modeltype+'file').files.length == 0){
      alert('没有选择文件')
      return
    }
    helpdom = $(this).nextAll('.help-inline')
    helpdom.text("开始上传")
    $.ajax({
      url: '/Index/picupload',
      type: 'POST',
      data: data,
      processData: false,
      contentType: false,
      dataType : 'json',
    }).done(function(ret){
      if (ret) {
        if(ret.code == "1"){
          helpdom.text("上传成功")
          $('input[name="'+modeltype+'url"]').val(ret.content[modeltype+'url'])
          $('#readimg').attr("src", ret.content[modeltype+'url']);
        } else {
          helpdom.text(ret.info)
        }
      }else{
        alert('上传失败');
      }
    });
  })

  $('.picup1').click(function() {
    var modeltype = $(this).attr('mtype')
    var data = new FormData()
    for(var key in document.getElementById(modeltype+'file1').files) {
        data.append(modeltype+'[]', document.getElementById(modeltype+'file1').files[key]);
      }
    if(document.getElementById(modeltype+'file1').files.length == 0){
      alert('没有选择文件')
      return
    }
    helpdom = $(this).nextAll('.help-inline')
    helpdom.text("开始上传")
    $.ajax({
      url: '/Index/picupload1',
      type: 'POST',
      data: data,
      processData: false,
      contentType: false,
      dataType : 'json',
    }).done(function(ret){
      if (ret) {
        if(ret.code == "1"){
          helpdom.text("上传成功")
          $('input[name="'+modeltype+'url1"]').val(ret.content[modeltype+'url1'])
          $('#readimg1').attr("src", ret.content[modeltype+'url1']);
        } else {
          helpdom.text(ret.info)
        }
      }else{
        alert('上传失败');
      }
    });
  })

  $('.picup2').click(function() {
    var modeltype = $(this).attr('mtype')
    var data = new FormData()
    for(var key in document.getElementById(modeltype+'file2').files) {
        data.append(modeltype+'[]', document.getElementById(modeltype+'file2').files[key]);
      }
    if(document.getElementById(modeltype+'file2').files.length == 0){
      alert('没有选择文件')
      return
    }
    helpdom = $(this).nextAll('.help-inline')
    helpdom.text("开始上传")
    $.ajax({
      url: '/Index/picupload2',
      type: 'POST',
      data: data,
      processData: false,
      contentType: false,
      dataType : 'json',
    }).done(function(ret){
      if (ret) {
        if(ret.code == "1"){
          helpdom.text("上传成功")
          $('input[name="'+modeltype+'url2"]').val(ret.content[modeltype+'url2'])
          $('#readimg2').attr("src", ret.content[modeltype+'url2']);
        } else {
          helpdom.text(ret.info)
        }
      }else{
        alert('上传失败');
      }
    });
  })

  $('input[type="file"]').change(function(){
    _this = $(this)
    num = this.files.length
    helpdom = _this.parent().nextAll('.help-inline')
    helpdom.text('选择了' + num +'个文件')
    helpdom.show()
  })
</script>
</body>
</html>